/*
** env.h for 42sh in /home/guina_b/
** 
** Made by benoit guina
** Login   <guina_b@epitech.net>
** 
** Started on  Fri Jan 01 00:00:00 2010 benoit guina
** Last update Fri Jan 01 00:00:00 2010 benoit guina
*/

#ifndef H_ENV
#define H_ENV

/*
**  ---         ---   env->data:
**  |           |     [0]: *var0
**  |           |len  [1]: *var1
**  |alloc_size |     [2]: *var2
**  |           ---4  [3]: *NULL  additional NULL ptrs avoid frequent
**  |                 [4]: *NULL  reallocations when new variables are set
**  |                 [5]: *NULL    
**  ---6
*/

typedef struct s_env
{
  char **data;
  unsigned int len;
  unsigned int alloc_size;
} t_env;

t_env *env_init(char **env_data, unsigned int alloc_size);
void env_free(t_env *env);

char **env_get_var(t_env *env, char *var);
char *env_get_var_value(t_env *env, char *var);
int env_set_var(t_env *env, char *var);
int env_unset_var(t_env *env, char *var);

/*
**  private, you should not have to use these
*/

char **env_copy_data(char **env_data, unsigned int *alloc_size);
void env_free_data(char **env_data);

#endif
